<template>
	<view class="turnover">
		<headerVue ref="header" :query="shopInfo" @toggle="toggle"  @changeIndex="changeHeaderIndex" @dateConfirm="dateConfirm"></headerVue>
		<FieldPopupVue :popupShow="popupShow" :FieldList="Field" @sure="sure" @changeActiveIndex="changeActiveIndex"
			:activeIndex="FieldIndex"></FieldPopupVue>
		<view class="center_box">
			<view class="Item mb"  @click="routeRecord(0)">
				<view class="header">
					<view class="left">
						会员卡营业额
					</view>
					<view>
						￥{{info.card_info.cost}}
					</view>
				</view>
				<view class="bottom">
					<view class="com_Item mr" >
						<view class="top_bottom">
							<view class="top_size">
								月卡(张)
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
						<view class="num">
							{{info.card_info.month_num}}
						</view>
					</view>
					<view class="com_Item mr" >
						<view class="top_bottom">
							<view class="top_size">
								季卡(张)
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
						<view class="num">
							{{info.card_info.season_num}}
						</view>
					</view>
					<view class="com_Item mr" >
						<view class="top_bottom">
							<view class="top_size">
								年卡(张)
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
						<view class="num">
							{{info.card_info.year_num}}
						</view>
					</view>
					<view class="com_Item " >
						<view class="top_bottom">
							<view class="top_size">
								其他卡(张)
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
						<view class="num">
							{{info.card_info.rest}}
						</view>
					</view>
				</view>
			</view>
			<view class="Item "  @click="routeRecord(1)">
				<view class="header">
					<view class="left">
						课程营业额
					</view>
					<view>
						￥{{info.course_info.cost}}
					</view>
				</view>
				<view class="bottom">
					<view class="com_Item mr" >
						<view class="top_bottom">
							<view class="top_size">
								私教课(节)
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
						<view class="num">
							{{info.course_info.course_num}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="foot_box">
			<view class="top">
				<view class="row_box">
					<text class="left">
						小程序营业额
					</text>
					<text>￥{{info.cost_info.wechat_cost}}</text>
				</view>
				<view class="row_box">
					<text class="left">
						收款码营业额
					</text>
					<text>￥{{info.cost_info.bank_cost}}</text>
				</view>
			</view>
			<view class="bottom2">
				<view class="row_box2">
					<text class="left">
						门店总营业额
					</text>
					<text>￥{{info.cost_info.all_cost}}</text>
				</view>
			</view>
		</view>
		<view class="empty">
			详细明细，请移至PC端后台查看
		</view>
	</view>
</template>

<script>
	import headerVue from './components/header.vue'
	import FieldPopupVue from '../../pages/user/components/Field-popup.vue'
	import{
		atShop,
		storefinanceturnover
	} from '@/api/manager.js'
	export default {
		components: {
			headerVue,
			FieldPopupVue
		},

		data() {
			return {
				query:{
					date:'',
					form:'day',
					shop_id:''
				},
				info:{},
				// 切换门店
				popupShow: false,
				shopInfo:{},
				Field: [],
				FieldIndex: -1,
			}
		},
		mounted() {
			this.query.date = this.$refs.header.day
			this.getatShop()
			this.getstorefinanceturnover()
		},
		methods: {
			getstorefinanceturnover(){
				storefinanceturnover(this.query).then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						this.info = res.data
					}
				})
			},
			getatShop(e){
				atShop(e).then(({data:res})=>{
					if(res.code == 1){
						this.shopInfo = res.data
						console.log('res', this.shop_info);
					}
				})
			},
			dateConfirm(e, data){
				console.log('e321', data);
				this.query.date = data
				this.getstorefinanceturnover()
			},
			changeHeaderIndex(e){
				console.log('e', e);
				this.query.form = e == 0 ? 'day' : e == 1 ? 'month' : 'year'
				this.query.date = this.$refs.header.day
				this.getstorefinanceturnover()
			},
			toggle() {
				console.log(11);
				this.popupShow = true
			},
			changeActiveIndex(item, index) {
				this.FieldIndex = index
				this.query.shop_id = item.shop_id
				this.getatShop({
					shop_id: item.shop_id
				})
				this.getstorefinanceturnover()
			},
			sure() {
				this.popupShow = false
			},
			routeRecord(index){
				if(!index){
					uni.navigateTo({
						url:'memberSalesRecord'
					})
				}else{
					uni.navigateTo({
						url:'CourseSalesRecord'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.turnover {
		display: flex;
		flex-direction: column;
		align-items: center;

		.center_box {
			margin-top: 24rpx;
			width: 702rpx;
			padding: 24rpx;
			background: #ffffff;
			border-radius: 32rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			.mb {
				margin-bottom: 24rpx;
			}

			.Item {
				display: flex;
				flex-direction: column;
				align-items: center;
				width: 654rpx;
				border-radius: 32rpx;
				overflow: hidden;
				background: linear-gradient(180deg, #73F0EA, rgba(129, 202, 197, 0.80));
				border: 2rpx solid #73F0EA;

				.header {
					width: 100%;
					padding: 24rpx 32rpx 56rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;
					text-align: left;
					color: #ffffff;
					display: flex;
					flex-direction: row;
					margin-bottom: 48rpx;

					.left {
						flex: 1;
					}
				}

				.bottom {
					margin-top: -72rpx;
					width: 654rpx;
					height: 150rpx;
					background: #ffffff;
					border-radius: 32rpx;
					z-index: 99;
					padding: 32rpx;
					display: flex;
					flex-direction: row;

					.mr {
						margin-right: 51.5rpx;
					}

					.com_Item {
						display: flex;
						flex-direction: column;

						.top_bottom {
							display: flex;
							flex-direction: row;
							align-items: center;
							margin-bottom: 8rpx;

							.top_size {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Regular;
								font-weight: 400;
								color: #666666;
							}
						}

						.num {
							font-size: 36rpx;
							font-family: DIN, DIN-Bold;
							font-weight: 700;
							text-align: left;
							color: #000000;
						}
					}
				}
			}
		}

		.foot_box {
			margin-top: 20rpx;
			width: 702rpx;
			background: #ffffff;
			border-radius: 32rpx;
			padding: 32rpx;
			.top {
				width: 100%;
				display: flex;
				flex-direction: column;
				border-bottom: 2rpx solid #f8f8f8;
				.row_box {
					width: 100%;
					display: flex;
					flex-direction: row;
					align-items: center;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					color: #000000;
					margin-bottom: 30rpx;

					.left {
						flex: 1;
					}
				}
			}
			.bottom2{
				display: flex;
				flex-direction: row;
				align-items: center;
				width: 100%;
				padding-top: 32rpx;
				.row_box2 {
					width: 100%;
					display: flex;
					flex-direction: row;
					align-items: center;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 700;
					color: #000000;
				
					.left {
						flex: 1;
					}
				}
			}
		}
		.empty{
			width: 100%;
			padding-top: 32rpx;
			display: flex;
			justify-content: center;
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			text-align: center;
			color: #999999;
		}
	}
</style>